<template>
    <div class="session flex flex-col bg-white">
      <el-select v-model="values" placeholder="请选择" @change="changeList">
        <el-option
            v-for="(item,index) in options"
            :key="index"
            :label="'任务' + item.date"
            :value="item.batch_key">
        </el-option>
      </el-select>
        <div class="flex-1 min-h-0">
            <ElScrollbar>
              <div @click="xiazia" class="sz">
                批量下载
              </div>
              <el-main>
                <el-table :data="itemData">
                  <el-table-column prop="key_num" label="序号" width="120">
                  </el-table-column>
                  <el-table-column prop="ask" label="任务内容" width="320">
                    <template #default="{ row }">
                      <div @click="tiaozhuan(row.category_id)">
                        {{row.ask}}
                      </div>
                      <div style="display: none">
                        <Markdown
                            :recordId="row.id"
                            :content="row.reply[0]"
                        ></Markdown>
                      </div>

                    </template>
                  </el-table-column>
                  <el-table-column prop="batch_status" label="状态" width="100" align="center">
                    <template #default="{ row }">
                      <div v-if="row.batch_status == 0" style="color: gold;text-align: center">
                        处理中
                      </div>
                      <div v-if="row.batch_status == 1" style="color: gold;text-align: center">
                        处理中
                      </div>
                      <div v-if="row.batch_status == 2" style="color: green;text-align: center">
                        完成
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="key_num" label="下载" width="120">
                    <template #default="{ row }">
                      <div @click="danduxiazai(row)" v-if="row.batch_status == 2" class="dsz">下载</div>
                    </template>
                  </el-table-column>
                </el-table>
              </el-main>

            </ElScrollbar>
        </div>
    </div>
</template>
<script lang="ts" setup>
import Item from './item.vue'
import { useAppStore } from '~/stores/app'
import {downloadWords} from "~/api/my";
import {ElMessageBox} from "element-plus";
const props = withDefaults(
    defineProps<{
      itemData: [],
      options:[]
    }>(),
    {}
)
const values = ref('')
const emit = defineEmits(['updateHide'])
const appStore = useAppStore()
if (appStore.getChatConfig.is_reopen) {
    appStore.getChatConfig.is_reopen = 0
}

const changeList = () => {
  emit('updateHideList',values);
}

const xiazia = () => {
  emit('wordsAll',props.itemData);
}

const danduxiazai = (item) => {
  emit('words',[item]);
}


const updateHide = (value) => {
  console.log('执行了吗')
  emit('updateHide',value);
}

function tiaozhuan(id){
  emit('updateHide',id)
}

</script>
<style lang="scss" scoped>
.session {
    height: 100%;
    border-radius: 16px;
}
.sz {
  margin-top: 20px;
  padding-left: 4px;
  color: green;
  cursor: pointer;
}
.dsz {
  color: green;
  cursor: pointer;
}
</style>
